<?php
include "templates/page_start.tpl";
?>

<script>$('#breadcrumb').append('Objekt Details | Objekt Nr: 000002');</script>

<table id="obj_detail">
    <tr>
        <td class="view_lable">Objekt Nummer:</td>
        <td class="view_data">
            <?php echo str_pad($data['object']["obj_id"], 6, '0', STR_PAD_LEFT); ?>
            <input type="hidden" name="obj_id" id = "obj_id" value="<?php echo $data['object']["obj_id"]; ?>" />

        </td>
    </tr> 
    <tr>
        <td class="view_lable"></td>
        <td><img width="<?php echo IMAGE_DEFAULT_W * IMAGE_VIEW_RATIO; ?>" src='<?php echo $data['object']["obj_img_url"]; ?>'></td>
    </tr>
    <tr>
        <td class="view_lable">Name:</td>
        <td><?php echo $data['object']["obj_name"] ?></td>
    </tr>
    <tr>
        <td class="view_lable">Objekt im Besitz:</td>
        <td>
            <?php
            if ($data['object']['obj_status'] == 1) {
                echo ANSWER_YES;
            } else {
                echo ANSWER_NO;
            }
            ?>
        </td>
    </tr>

    <tr>
        <td class="view_lable">Kategorie:</td>
        <td><?php echo $data['object']["obj_cat_id"] ?></td>
    </tr>
    <tr>
        <td class="view_lable">Manufaktur:</td>
        <td><?php echo get_field_input('manufacture', $data['object']["obj_man_id"]); ?></td>
    </tr>
    <tr>
        <td class="view_lable">Marke:</td>
        <td><?php echo get_field_input('lable', $data['object']["obj_lable_id"]); ?></td>

    </tr>

    <tr>
        <td class="view_lable">K&uuml;nstler Entwurf:</td>
        <td><?php echo get_field_input('artist', $data['object']["obj_artist_draft_id"]); ?></td>
    </tr>

    <tr>
        <td class="view_lable">K&uuml;nstler Design:</td>
        <td><?php echo get_field_input('artist', $data['object']["obj_artist_design_id"]); ?></td>
    </tr>

    <tr>
        <td class="view_lable">Datierung:</td>
        <td><?php echo $data['object']["obj_dating"]; ?></td>
    </tr>

    <tr>
        <td class="view_lable">H&ouml;he:</td>
        <td><?php echo $data['object']["obj_heigh"]; ?></td>
    </tr>

    <tr>
        <td class="view_lable">Besch&auml;digung:</td>
        <td>
            <?php
            if ($data['object']['obj_damage'] == 1) {
                echo ANSWER_YES;
            } else {
                echo ANSWER_NO;
            }
            ?>
        </td>
    </tr>


    <tr>
        <td class="view_lable">Kaufzeitpunkt:</td>
        <td><?php echo $data['object']['obj_pur_month'] . " / " . $data['object']['obj_pur_year']; ?></td>
    </tr>

    <tr>
        <td class="view_lable">Kaufort:</td>
        <td><?php echo get_field_input('place', $data['object']['obj_pur_place_id']); ?></td>
    </tr>

    <tr>
        <td class="view_lable">Kaufpreis:</td>
        <td><?php echo $data['object']['obj_pur_price']; ?> &euro;</td>
    </tr>

    <tr>
        <td class="view_lable">Vorbesitzer:</td>
        <td><?php echo get_field_input('person', $data['object']['obj_ancestor_person_id']); ?></td>
    </tr>


    <tr>
        <td class="view_lable">Geschenk:</td>
        <td>
            <?php
            if ($data['object']['obj_present'] == 1) {
                echo ANSWER_YES;
            } else {
                echo ANSWER_NO;
            }
            ?>
        </td>
    </tr>

    <tr>
        <td class="view_lable">Von:</td>
        <td><?php echo get_field_input('person', $data['object']['obj_present_person_id']); ?></td>
    </tr>


    <tr>
        <td class="view_lable">Kommentar:</td>
        <td><?php echo $data['object']['obj_comment'] ?></td>
    <tr>

    <tr>
        <td class="view_lable"></td>
        <td>
            <a id="obj_edit" href="#">Bearbeiten</a>
            <a id="obj_del" href="#">L&ouml;schen</a>
        </td>
    <tr>

</table>


<div id="obj_del_confirm" title="Objekt l&ouml;schen?">
    <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Sind sie sicher?</p>
</div>

<script>
    
    $(function() {
        $( "#obj_del" ).button();
        $( "#obj_del" ).click(function() {
            $( "#obj_del_confirm" ).dialog( "open" );
            
        });
        $( "#obj_edit" ).button();
    });
    
    $( "#obj_del_confirm" ).dialog({
        resizable: false,
        autoOpen: false,
        height:140,
        modal: true,
        buttons: {
            Ok: function() {
                var obj_id = $('#obj_id').val();
                console.log("Objekt ID: " + obj_id);
                $.post("?section=china&action=del", { "obj_id": obj_id } );
                $( this ).dialog( "close" );
                window.location.href = "?section=china&action=overview";
            },
            Abbrechen: function() {
                $( this ).dialog( "close" );
            }
        }
    });

</script>



<?php
include "templates/page_end.tpl";
?>
